import React from 'react';
import { useEffect } from 'react';

import {useSelector} from 'react-redux';
import TopicsList from '../component/topicsList';
import useTopicList from '../store/action/useTopicList';
// 职责分离：组件状态被集成到到 store，获取数据的方法也交给 store

const Index = () => {
  const tab = 'all',
    page = 1;
  const {loading,data} = useSelector( state => state.topics)

  let getData = useTopicList();

  useEffect( () => {

    getData(tab,page);

  },[tab,page])

  return  (
    <>
      <TopicsList data={data} loading={loading} />
    </>
  )
}

export default Index;